/**
 * Created by zy on 2017/6/5.
 */
angular.module('service.desk', [
        "ngResource"
    ])
    .service('DeskService', DeskService);
DeskService.$inject = ['$resource'];
function DeskService($resource) {
    var resource = $resource(mallurl+'/shopstable');

    //新增桌台
    this.add_desk = function (desk,successFn,errorFn) {
        return resource.save({},desk,successFn,errorFn);
    };

    //GET /shopstable/status/{shopid}/{status} 通过shopid和status,获取改shop下为status的接口
    this.get_status = function (shopid,status,successFn,errorFn) {
        var resources = $resource(mallurl+'shopstable/status/:shopid/:status');
        return resources.query({shopid:shopid,status:status},successFn,errorFn);
    };

    //GET /shopstable/{shopid} 通过id,获取接口
    this.get_desk1 = function (shopid) {
        var resources = $resource(mallurl+'shopstable/byshopid/:shopid');
        return resources.query({shopid:shopid});
    };

    //GET /shopstable/{shopid}/{stid} 通过商店id，桌台id,获取接口
    this.get_desk2 = function (shopid,deskid,successFn,errorFn) {
        var resources = $resource(mallurl+'shopstable/:shopid/:stid');
        return resources.get({shopid:shopid,stid:deskid},successFn,errorFn);
    };

    //DELETE /shopstable/{shopid}/{stid} 通过商店id，桌台id,删除接口
    this.delete_desk = function (shopid,deskid,successFn,errorFn) {
        var resources = $resource(mallurl+'shopstable/:shopid/:stid');
        return resources.remove({shopid:shopid,stid:deskid},successFn,errorFn);
    };

    //PUT /shopstable/{shopid}/{stid} 通过商店id，桌台id,更新接口
    this.modify_desk = function (shopid,deskid,desk,successFn,errorFn) {
        var resources = $resource(mallurl+'shopstable/:shopid/:stid');
        return resources.save({shopid:shopid,stid:deskid},desk,successFn,errorFn);
    };
}